home *** CD-ROM | disk | FTP | other *** search
- Path: mail2news.demon.co.uk!txwang
- From: Wang TianXing <gztxwang@public1.guangzhou.gd.cn>
- Newsgroups: comp.lang.c++
- Subject: Re: fastest code
- Date: Thu, 11 Apr 1996 13:03:34 GMT
- Message-ID: <199604111303.VAA11095@public1.guangzhou.gd.cn>
- X-NNTP-Posting-Host: txwang
- X-Newsreader: Forte Free Agent 1.0.82
- X-Mail2News-Path: public1.guangzhou.gd.cn!txwang
-
- On Tue, 09 Apr 1996 15:28:22 -0400, Sean Palmer <sean@delta.com>
- wrote:
-
- | Being dumb aside, if the (fictitious bad) compiler, for this C++ code:
-
- | void test(int& x) {
- | if (!(x==0))
- | x=x+1;
- | }
-
- | generates the following x86 asm code:
-
- [ lots of code deleted ]
-
- | while another compiler generates this code:
-
- | test@i:
- | mov ebx,[eax]
- | test ebx,ebx
- | jnz @@loc1
- | inc dword ptr [eax]
- | @@loc1:
- | ret
-
- | which would you rather call in a 10000-iteration loop?
-
- I'd prefer a compiler that could generate:
-
- test@i:
- cmp [eax], 1
- sbb [eax], -1
- ret
-
- Which compiler does this? :)
-
-
- --
- Wang TianXing
-
-
-